﻿Imports System.Data.SqlClient
Imports System.Configuration

Public Class frm_hocvien
    Dim tb As New DataTable
    Sub loadhv()
        Dim cmd As New SqlCommand("sp_hocvien_lenluoi", conn)
        cmd.CommandType = CommandType.StoredProcedure

        Dim da As New SqlDataAdapter(cmd)


        da.Fill(tb)
        dgv_dshv.DataSource = tb
    End Sub

    Private Sub frm_hocvien_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        loadhv()
    End Sub

    Private Sub cmd_timhv_Click(sender As System.Object, e As System.EventArgs) Handles cmd_timhv.Click
        If cbo_chon.SelectedIndex < 0 Then
            MsgBox("Vui lòng chọn mục cần tìm ")
            Exit Sub
        End If
        If cbo_chon.SelectedIndex = 0 Then
            tb.DefaultView.RowFilter = String.Format("MaHocVien like '%{0}'", txt_timhv.Text)
        End If
        If cbo_chon.SelectedIndex = 1 Then
            tb.DefaultView.RowFilter = String.Format("TenHocVien like '%{0}'", txt_timhv.Text)
        End If
    End Sub
End Class